#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <stdbool.h>
bool math(char** matrix, char* word, int i, int j, int matrixRowLen, int* matrixColLen)
{
    if (matrix[i - 1][j] == *word && i-1 >= 0 && i-1 < matrixRowLen && j >= 0 && j < *matrixColLen)
    {
        matrix[i - 1][j] = ' ';
        return math(matrix, word + 1, i - 1, j, matrixRowLen, matrixColLen);
    }
    else if (matrix[i + 1][j] == *word && i+1 >= 0 && i +1< matrixRowLen && j >= 0 && j < *matrixColLen)
    {
        matrix[i + 1][j] = ' ';
        return math(matrix, word + 1, i + 1, j, matrixRowLen, matrixColLen);
    }
    else if (matrix[i][j - 1] == *word && i >= 0 && i < matrixRowLen && j -1>= 0 && j-1 < *matrixColLen)
    {
        matrix[i][j - 1] = ' ';
        return math(matrix, word + 1, i, j - 1, matrixRowLen, matrixColLen);
    }
    else if (matrix[i][j + 1] == *word && i >= 0 && i < matrixRowLen && j +1>= 0 && j+1 < *matrixColLen)
    {
        matrix[i][j + 1] = ' ';
        return math(matrix, word + 1, i, j + 1, matrixRowLen, matrixColLen);
    }
    if (*word == '\0')
        return true;
    else
        return false;
}
bool hasPath(char** matrix, int matrixRowLen, int* matrixColLen, char* word)
{
    int i = 0;
    int j = 0;
    for (i = 0;i < matrixRowLen;i++)
    {
        for (j = 0;j < *matrixColLen;j++)
        {
            if (matrix[i][j] == *word)
            {
                matrix[i][j] = ' ';
                goto zhe;
            }
        }
    }
    // write code here
zhe:
    return math(matrix, word + 1, i, j, matrixRowLen, matrixColLen);
}
int main()
{
    char arr1[20];
    char arr[4][4];
    int a = 0;
    int* p = &a;
    int i = 0;
    int j = 0;
    scanf("%s", arr1);
    a = 4;

    for (i = 0;i < 4;i++)
    {
        for (j = 0;j < 4;j++)
        {
            scanf("%c", arr[i][j]);
        }
    }
    if (hasPath(arr, 4, p, arr1))
        printf("yes");
    return 0;
}